// pages/topersonalinto/topersonalinto.js
const app = getApp();
var ea = require('../../utils/each.js');
var WxParse = require('../../utils/wxParse/wxParse.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    headsrc: app.data.imgurl +"headimg.png",
    getmyhuiyuaninfo: app.data.url + 'sheyingjia/Xhuiyuan1/getmyhuiyuaninfo',
    jiaohuifei: app.data.url + 'sheyingjia/Xhuiyuan1/jiaohuifeigeren',
    shuju:{},//获取会员信息
    users:{},//我的个人信息
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var user = wx.getStorageSync('user');
    var that = this;
    ea.qinqiu(that.data.getmyhuiyuaninfo,{token:user.token},function(data){
      console.log(data);
      var shuju = data.data;
      WxParse.wxParse('article', 'html', data.soufei.geren.jianjie, that, 25);
      if(shuju.length==0){
        wx.showToast({
          title: '你还没有申请会员',
          icon:'none'
        })
        setTimeout(function(){
          wx.navigateBack({
            delta:1
          })
        },app.data.times)
      }
      var user = data.user;
      that.setData({shuju:shuju,users:user});
      if(shuju.huiyuan!=1){
        wx.showToast({
          title: '你申请的是团体会员',
          icon:'none'
        })
      }

    })
  },
  //个人缴费
  jiaofei:function(){
    var user = wx.getStorageSync('user');
    var shuju = this.data.shuju;
    var that = this;
    ea.qinqiu(that.data.jiaohuifei,{token:user.token,shuju:shuju},function(data){
      wx.requestPayment({
        timeStamp: data.timeStamp,
        nonceStr: data.nonceStr,
        package: data.package,
        signType: data.signType,
        paySign: data.paySign,
      })
    })
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})